//
//  HLIMKitMessageVideoContentView.m
//  YueYue
//
//  Created by hulu001 on 2024/1/12.
//

#import "HLIMKitMessageVideoContentView.h"

@interface HLIMKitMessageVideoContentView ()

@property (nonatomic, weak) UIImageView *icon;
@property (nonatomic, strong) CAShapeLayer *maskLayer;

@end

@implementation HLIMKitMessageVideoContentView


- (instancetype)init
{
    self = [super init];
    
    if (self) {
        self.opaque = YES;
        _imageView  = [[UIImageView alloc] initWithFrame:CGRectZero];
        _imageView.backgroundColor = [UIColor whiteColor];
        _imageView.contentMode = UIViewContentModeScaleAspectFill;
        _imageView.clipsToBounds = YES;
        _imageView.layer.cornerRadius = 4;
        [self addSubview:_imageView];
        
        UIImageView *icon = [UIImageView.alloc initWithImage:[UIImage imageNamed:@"im_video_play"]];
        [icon sizeToFit];
        [self addSubview:icon];
        self.icon = icon;
    }
    
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.imageView.frame = self.bounds;
    
    self.icon.center = self.middlePoint;
}

- (void)refreshData:(HLIMKitMessageModel *)messageModel
{
    [super refreshData:messageModel];
    
    NIMVideoObject *videoObject = (NIMVideoObject *)messageModel.message.messageObject;
    
    self.imageView.image = [UIImage imageWithContentsOfFile:videoObject.coverPath];
}


@end
